#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int HaoShu[10005];
void ChuShiHuaShuZu();
int main()
{
    int n, t;
    ChuShiHuaShuZu();
    scanf("%d", &n);

    while(n--)
    {
        scanf("%d", &t);
        if (HaoShu[t] == 0)
        {
            while (HaoShu[t] == 0)
            {
                t++;
            }
            printf("No %d\n", t);
        }
        else
        {
            printf("Yes\n");
        }

        for (int i = 1; i <= 100; i++)
        {
            for (int j = i + 1; j <= 100; j++)
            {
                int m = i * i + i * j + j * j;
                if (m == t)
                {
                    printf("%d %d\n", i, j);
                }
            }
        }
    }
    return 0;
}
void ChuShiHuaShuZu()
{
    memset(HaoShu, 0, sizeof HaoShu);
    for (int i = 1; i <= 100; i++)
    {
        for (int j = i + 1; j <= 100; j++)
        {
            int t = i * i + i * j + j * j;
            if (t <= 10005)
            {
                HaoShu[t] = 1;
            }
        }
    }
}